package socket.chat;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashSet;
import java.util.Set;

public class Server {
	private ServerSocket server;
	private Set<Socket> cs;

	public Server() {
		cs = new HashSet<>();		
		try {
			server = new ServerSocket(8088);
			while (true) {
				Socket socket = server.accept();
				cs.add(socket);
				System.out.println(socket.getInetAddress().getHostAddress()+"进来了");
				Receiver rc=new Receiver(socket, cs);
				rc.start();
			}
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	public static void main(String[] args) {
		new Server();
	}
}
